<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import instance from "../assets/axiosinstance";
import { Calendar, Search, User } from "@element-plus/icons-vue";
const input2 = ref("admin");
const input3 = ref("atguigu123");
const router = useRouter();
const instance1 = async () => {
  const res = await instance.post("/admin/acl/index/login", {
    password: input3.value,
    username: input2.value,
  });
  if (res.code == 200) {
          window.localStorage.setItem("token", res.data);
      const res1 = await instance.get("/admin/acl/index/info");
window.localStorage.setItem("avator",res1.data.avatar);
window.localStorage.setItem("name",res1.data.name);
  window.localStorage.setItem("roles",JSON.stringify(res1.data.roles))
  
    
    router.push({
      path: "/index",
     

    });
  }
  //   const res1 = await instance.get("/admin/acl/index/info");
  // console.log(res)
  //   console.log(res1)
};
</script>

<template>
  <div class="login">
    <div class="loginform">
      <div class="logintitle">欢迎来到BLAZER甄选系统</div>
      <el-input
        v-model="input2"
        class="w-50 inputlb m-2"
        placeholder="Type something"
      >
        <template #prefix>
          <el-icon class="el-input__icon"><user /></el-icon>
        </template>
      </el-input>
      <el-input
        v-model="input3"
        type="password"
        class="w-50 inputlb m-2"
        placeholder="Type something"
      >
        <template #prefix>
          <el-icon class="el-input__icon"><user /></el-icon>
        </template>
      </el-input>
      <el-button type="primary" style="width: 100%" @click="instance1"
        >登录</el-button
      >
    </div>
  </div>
</template>
<style>
.inputlb {
  width: 100%;
  height: auto;
  margin-bottom: 35px;
}
</style>
<style scoped>
.logintitle {
  color: #fff;
  text-align: center;
  font-size: 20px;
  margin-bottom: 15px;
}
.loginform {
  width: 50%;
  height: 330px;
  position: absolute;
  padding: 15px;
  box-sizing: border-box;
  top: 30%;
  left: 27%;
  background: url("../assets/login_form.png") no-repeat;
  background-size: 100% 100%;
}
.login {
  width: 100%;
  height: 100%;
  background: url("../assets/background.jpg") no-repeat;
  background-size: 100% 100%;
  position: relative;
}
</style>
